Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
How to make this javascript code better? works for A-B-C destinations, but is not dynamic, there's a bag when I want to go to destination "D"

Could be an algorithm issue.

used

var markers = new Map(); (for markers)
var routes = new Array(); (for lines from pt a to b and etc)

const step = (pointsObj) => {
    if (pointsObj.i < routes.length) {

        if (routes.length > 1)

        // move the user along the line by 1 step ()
        var pointA = routes[pointsObj.i];
        var pointB = routes[pointsObj.i + 1];

        // user moving gradually to the next point
        userMarker.setLatLng(
            new L.LatLng(
                userMarker.getLatLng().lat + (pointB.lat - pointA.lat) / maxNumSteps,
                userMarker.getLatLng().lng + (pointB.lng - pointA.lng) / maxNumSteps
            )
        );

        // number of steps user taking to move forward

        currentNumSteps++;
        // once the user reaches point B, set pointA = pointB and pointB = point C
        if (currentNumSteps == maxNumSteps) pointsObj.i++;
    }
};
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda